//
//  PublishViewController.m
//  Snail School
//
//  Created by 厘米网络 on 15/12/26.
//  Copyright © 2015年 himooo. All rights reserved.
//

#import "PublishViewController.h"
#import <Masonry.h>
#import "commond.h"
@interface PublishViewController ()<UITextViewDelegate>
//
@property(strong,nonatomic)UIView *headView;
//
@property(strong,nonatomic)UIButton *btnBak;
//
@property(strong,nonatomic)UILabel *lblTheme;
//
@property(strong,nonatomic)UITextField *themeTextField;
//
@property(strong,nonatomic)UIImageView *lineImageView;
//
@property(strong,nonatomic)UITextView *detailTextView;
//
@property(strong,nonatomic)UILabel *detailTextViewPlaceholder;
//
@property(strong,nonatomic)UIButton *btnImage;

@end

@implementation PublishViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor=[UIColor whiteColor];
    [self initViews];
    // Do any additional setup after loading the view.
}
-(void)initViews
{
    __weak typeof(self) weakSelf=self;
    //头部视图
    self.headView=[[UIView alloc]init];
    self.headView.backgroundColor=[UIColor grayColor];
    [self.view addSubview:self.headView];
    [self.headView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.mas_equalTo(CGSizeMake(WIDTH, 70));
        make.top.and.left.and.right.mas_equalTo(0);
    }];
    //
    self.btnBak=[UIButton buttonWithType:UIButtonTypeCustom];
    [self.btnBak setBackgroundImage:[UIImage imageNamed:@"cancel.png"] forState:UIControlStateNormal];
    [self.headView addSubview:self.btnBak];
    [self.btnBak mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.mas_equalTo(CGSizeMake(25, 25));
        make.top.and.left.mas_equalTo(20);
    }];
    [self.btnBak addTarget:self action:@selector(btnBackClick) forControlEvents:UIControlEventTouchUpInside];
    //
    self.lblTheme=[[UILabel alloc]init];
    self.lblTheme.backgroundColor=[UIColor whiteColor];
    self.lblTheme.text=@"发布";
    self.lblTheme.textAlignment=NSTextAlignmentCenter;
//    self.lblTheme.font=[UIFont systemFontOfSize:12];
    [self.headView addSubview:self.lblTheme];
    [self.lblTheme mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.mas_equalTo(CGSizeMake(100, 40));
        make.left.equalTo(weakSelf.view.mas_centerX).offset(-50);
        make.top.mas_equalTo(15);
//        make.left.mas_equalTo(WIDTH/2-50);
    }];
    //
    self.themeTextField=[[UITextField alloc]init];
    [self.view addSubview:self.themeTextField];
    [self.themeTextField mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.mas_equalTo(CGSizeMake(WIDTH-40, 40));
        make.left.mas_equalTo(20);
        make.top.mas_equalTo(self.headView.mas_bottom).offset(10);
    }];
    self.themeTextField.placeholder=@"标题";

    [self.themeTextField setValue:[UIFont systemFontOfSize:15] forKeyPath:@"placeholderLabel.font"];
    //
    self.lineImageView=[[UIImageView alloc]init];
    self.lineImageView.backgroundColor=[UIColor lightGrayColor];
    [self.view addSubview:self.lineImageView];
    [self.lineImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.mas_equalTo(CGSizeMake(WIDTH-40, 2));
        make.top.mas_equalTo(self.themeTextField.mas_bottom).offset(0);
        make.left.mas_equalTo(20);
        make.right.mas_equalTo(-20);
    }];
    //
    self.detailTextView=[[UITextView alloc]init];
    self.detailTextView.backgroundColor=[UIColor redColor];
    self.detailTextView.delegate=self;
    [self.view addSubview:self.detailTextView];
    [self.detailTextView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.mas_equalTo(CGSizeMake(WIDTH-40, 100));
        make.left.mas_equalTo(20);
        make.right.mas_equalTo(-20);
        make.top.mas_equalTo(self.lineImageView.mas_bottom).offset(0);
    }];
    //
    self.detailTextViewPlaceholder=[[UILabel alloc]init];
    [self.detailTextView addSubview:self.detailTextViewPlaceholder];
    self.detailTextViewPlaceholder.text=@"描述你想出租的物品信息.....";
    self.detailTextViewPlaceholder.font=[UIFont systemFontOfSize:14];
    self.detailTextViewPlaceholder.textColor=[UIColor grayColor];
    [self.detailTextViewPlaceholder mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.mas_equalTo(CGSizeMake(150, 30));
        make.top.mas_equalTo(self.detailTextView.mas_top).offset(0);
        make.left.mas_equalTo(self.detailTextView.mas_left).offset(0);
    }];
    //
    self.btnImage=[UIButton buttonWithType:UIButtonTypeCustom];
    [self.view addSubview:self.btnImage];
    [self.btnImage mas_makeConstraints:^(MASConstraintMaker *make) {
        
    }];
    
}
//textview的代理事件
- (void)textViewDidBeginEditing:(UITextView *)textView
{
    self.detailTextViewPlaceholder.hidden=YES;
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}
-(void)btnBackClick
{
    [self dismissViewControllerAnimated:YES completion:nil];
}
/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
